home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 6.2 KB | 231 lines | [TEXT/MPS ] |
- {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
-
- { UTEDocument.p }
- { Copyright © 1990 by Apple Computer, Inc. All rights reserved. }
-
- {
- This separate unit for TE Documents is still an example and not a supported Building Block.
- It provides a backing document for those times when you want to write your TEView to external
- media. Remember, since its not a building block right now the structure is subject to more
- than the usual amount of change. Let us know what you think.
- }
-
- UNIT UTEDocument;
-
- INTERFACE
-
- USES
- { • MacApp }
- UMacApp,
-
- { • Building Blocks }
- UPrinting, UTEView,
-
- { • Required for this unit's interface }
-
- { • Implementation use }
- ToolUtils, Fonts, Resources, Script, Picker;
-
- CONST
-
- kTextFileType = 'TEXT'; { Standard file-type code for saved disk
- files -- uses standard text files }
- kWindowRsrcID = 1004; { 'view' template for a DemoText window }
- kViewRsrcID = 1005; { 'view' template for a DemoText view }
-
- { Menu numbers }
- mFont = 10;
-
- { Command numbers }
-
- cWidthSuperView = 601; { View-width-determination commands }
- cWidthView = 602;
- cWidthOnePage = 603;
-
- cHeightSuperView = 604; { View-height-determination commands }
- cHeightPages = 605;
- cHeightText = 606;
- cHeightConst = 607;
-
- cJustForceLeft = 608; { Justification commands }
- cJustCenter = 609;
- cJustRight = 610;
- cJustSystem = 611;
-
- { Command numbering scheme:
- styles = 1000
- sizes = 1100
- just = 1200
- fonts = 1300
- hiers = 1400
- colors = 1500
- }
-
- { Command numbers for typestyle attributes }
- cPlainText = 1001;
- cBold = 1002;
- cItalic = 1003;
- cUnderline = 1004;
- cOutline = 1005;
- cShadow = 1006;
- cCondense = 1007;
- cExtend = 1008;
-
- { Command numbers for font-size commands }
- cSizeChange = 1100;
- cSizeBase = 1100;
- cSizeMin = 1109;
- cSizeMax = 1124;
- { 1101-1197 reserved for font sizes 1-97 pts. }
- cSizeGrow = 1198;
- cSizeShrink = 1199;
-
- { Command numbers to cover other stylistic changes }
- cJustChange = 1200;
- cFontChange = 1300;
-
- { Command numbers for the hierarchial menu }
- cStyle = 1401;
- cSize = 1402;
- cFont = 1403;
- cColor = 1404;
-
- { Command numbers for changing colors }
- cColorChange = 1500;
- cColorText = 1501;
- cColorBackground = 1502;
-
- { Constant for staggering windows }
- kStaggerAmount = 16;
-
- { Constant for amount to relative size text selection }
- kRelSizeAmount = 4;
-
- { Constants for the text specs resource }
- kTextSpecsRsrcType = 'SPEC';
- kTextSpecsRsrcID = 1;
-
- { Constants for the text style resource }
- kTextStyleRsrcType = 'STYL';
- kStylesRsrcID = 1;
- kElementsRsrcID = 2;
-
- { Constants for the print info resource }
- kPrintInfoRsrcType = 'PRNT';
- kPrintInfoRsrcID = 1;
-
- { Constants for the prompts string list }
- kPromptsRsrcID = 1005;
- kColTextPrompt = 1;
- kColBackPrompt = 2;
-
- { The 'File is too large' alert }
- kFileTooBig = 1000;
-
- kHierDisplayedMBar = 131; { Displayed menus on hier. menu system }
- kNonHierDisplayedMBar = 128; { Displayed menus on non-hier. system }
-
- kHierMenuOffset = 1000; { Offset added to non-hier menu cmds to get
- the right number }
-
- TYPE
-
- TextSpecs = { Additional document specifications }
- RECORD
- theTextFont: Str255;
- theTextFace: Style;
- theTextSize: INTEGER;
- theTextColor: RGBColor;
- theJustification: INTEGER; { record justification }
- theBackColor: RGBColor; { Window's background color }
- END;
- TextSpecsPtr = ^TextSpecs;
- TextSpecsHdl = ^TextSpecsPtr;
-
- TTEDocument = OBJECT (TDocument)
-
- fDocText: Handle; { The text owned by the document }
- fStyles: TEStyleHandle; { Style handle, if any }
- fElements: STHandle; { Handle to element array, if any }
- fTEView: TTEView; { The view which displays the text }
- fTextSpecs: TextSpecs; { Specifies properties of the text }
-
- { Initialization and freeing }
-
- PROCEDURE TTEDocument.ITEDocument(itsFileType, itsCreator: OSType;
- usesDataFork, usesRsrcFork: BOOLEAN;
- keepsDataOpen, keepsRsrcOpen: BOOLEAN);
- { Initialization method for TDocument. }
- PROCEDURE TTEDocument.Free; OVERRIDE;
- PROCEDURE TTEDocument.DoInitialState; OVERRIDE;
- PROCEDURE TTEDocument.FreeData; OVERRIDE;
-
- { Filing }
-
- PROCEDURE TTEDocument.DoNeedDiskSpace(VAR dataForkBytes,
- rsrcForkBytes: LONGINT); OVERRIDE;
- PROCEDURE TTEDocument.DoRead(aRefNum: INTEGER;
- rsrcExists, forPrinting: BOOLEAN); OVERRIDE;
- PROCEDURE TTEDocument.DoWrite(aRefNum: INTEGER;
- makingCopy: BOOLEAN); OVERRIDE;
-
- { Making views and windows }
-
- PROCEDURE TTEDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
-
- { Command processing }
-
- FUNCTION TTEDocument.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- PROCEDURE TTEDocument.DoSetupMenus; OVERRIDE;
-
- { Auxiliary routines }
-
- PROCEDURE TTEDocument.ChangeBackColor(newColor: RGBColor);
-
- PROCEDURE TTEDocument.SetSpecStyle;
-
- PROCEDURE TTEDocument.ShowReverted; OVERRIDE;
- { When the user reverts a document, this is called after reading
- the old document and before displaying it. Causes the reverted
- font specs to be installed. }
-
- { Inspecting }
-
- PROCEDURE TTEDocument.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TJustCommand = OBJECT (TCommand)
- fTEView: TTEView;
- fOldJust: INTEGER;
- fNewJust: INTEGER;
-
- PROCEDURE TJustCommand.IJustCommand(itsTEView: TTEView;
- itsNewJust: INTEGER);
-
- PROCEDURE TJustCommand.DoIt; OVERRIDE;
-
- PROCEDURE TJustCommand.RedoIt; OVERRIDE;
-
- PROCEDURE TJustCommand.UndoIt; OVERRIDE;
-
- PROCEDURE TJustCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- VAR
- gDefaultSpecs: TextSpecs; { Text specs as default for new documents }
- gStaggerCount: INTEGER;
-
- IMPLEMENTATION
-
- {$I UTEDocument.inc1.p}
-
- END.
-